<template>
  <a-config-provider :locale="locale">
    <component :is="currentLayout" />
  </a-config-provider>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import BasicLayout from '@/layouts/BasicLayout.vue'
import AuthLayout from '@/layouts/AuthLayout.vue'
import zhCN from 'ant-design-vue/es/locale/zh_CN'
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'

// 配置dayjs中文语言
dayjs.locale('zh-cn')

// 中文语言配置
const locale = zhCN

const route = useRoute()

// 根据当前路由决定使用哪个布局
const currentLayout = computed(() => {
  // 认证相关页面使用 AuthLayout
  if (route.path.startsWith('/user/login') || route.path.startsWith('/user/register')) {
    return AuthLayout
  }
  // 其他页面使用 BasicLayout
  return BasicLayout
})
</script>

<style scoped></style>
